package apii.servlet.prof;

import static apii.servlet.prof.ProfUtils.*;

import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import apii.server.*;

// assigned by root address: /prof
// assigned by web.xml address: /prof_home_servlet
public class ProfHomeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		try (Connection c = ServerThings.getThings().getConnection();) {
			ProfData profData = getSessionProf(c, request);
			if (profData == null) {
				redirectToLogin(response);
				return;
			}
			startResponse(response, "Домашняя страница преподавателя", profData);
			homeResponse(response);
			finishResponse(response);
		} catch (SQLException e) {
			e.printStackTrace();
			redirectToException(response);
		}
	}
}
